package com.mine.androidlearn.tempnet;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import com.mine.androidlearn.R;
import com.mine.androidlearn.api.bean.WeatherInfoBean;
import com.mine.androidlearn.common.base.BaseMvpActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class NetActivity extends BaseMvpActivity<INetContract.view, NetPresenter> implements INetContract.view {


    @BindView(R.id.btnGetWeather)
    Button btnGetWeather;
    @BindView(R.id.tvTemperature)
    TextView tvTemperature;

    @Override
    protected NetPresenter createPresenter() {
        return new NetPresenter(this);
    }

    @Override
    protected void initVariables() {

    }

    @Override
    protected void initViews(Bundle savedInstanceState) {
        setContentView(R.layout.activity_net);
    }

    @Override
    protected void loadData() {

    }

    @Override
    public void loadWeatherInfoSuccess(WeatherInfoBean weatherInfoBean) {
        tvTemperature.setText("当前的气温为：" + weatherInfoBean.getResult().getRealtime().getWeather().getTemperature() + "℃");
    }

    @Override
    public void showServerOrNetworkError() {

    }

    @Override
    public void showNetworkNotConnected() {

    }

    @Override
    public void showApiError(String error) {

    }

    @Override
    public void showLoading() {
        showLoadingDialog("", true);
    }

    @Override
    public void hideLoading() {
        hideLoadingDialog();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.btnGetWeather)
    public void onViewClicked() {
        mPresenter.loadWeatherInfo("c5bb749112664353af44bc99ed263857", "长沙");
    }
}
